package com.hopu.community_task.action;

import java.util.Map;

import com.hopu.community_task.domain.Userinfo;
import com.hopu.community_task.service.UserinfoServic;
import com.hopu.community_task.service.impl.UserinfoServicImpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class UserAction extends ActionSupport implements ModelDriven<Userinfo> {

	private Userinfo user = new Userinfo();
	private UserinfoServic service = new UserinfoServicImpl(); 
	public String login() {
		user = service.login(user.getUname(), user.getUpwd());
		if(user!=null) {
			ActionContext.getContext().getSession().put("userinfo", user);
			return SUCCESS;
		}else {
			Map request = (Map) ActionContext.getContext().get("request");
			request.put("login_message","-1");
			return LOGIN;
		}
	}
	
	
	
	
	
	
	
	
	@Override
	public Userinfo getModel() {
		return user;
	}

}
